package com.ty.day4;

/**
 * Created by IntelliJ IDEA.
 * Author : txy
 * Create 2023/10/31 14:27
 */
public class Six {
    public static void main(String[] args) {
        int count = 0;
        System.out.println("101~200的素数有：");
        for (int i = 101; i <= 200; i++) {
            if (Prime(i) == 1) {
                count++;
                System.out.print(i + " ");
            }
        }
        System.out.println("\n一共" + count + "个");
    }

    public static int Prime(int a) {
        int flag = 1;
        for (int i = 2; i <= Math.sqrt(a); i++) {
            if (a % i == 0) {
                flag = 0;
                break;
            }
        }
        return flag;
    }
}
